﻿@model CustomerInfoModel
@using Nop.Web.Models.Customer;
@using Nop.Core;
@{
    Layout = "~/Views/Shared/_ColumnsTwo.cshtml";

    //title
    Html.AddTitleParts(T("PageTitle.Account").Text);
}
@section left
{
    @Html.Action("CustomerNavigation", "Customer", new { selectedTabId = CustomerNavigationEnum.Addresses })
}
@if (Model.CountryEnabled && Model.StateProvinceEnabled)
{
    <script type="text/javascript">
        $(function () {
            $("#@Html.FieldIdFor(model => model.CountryId)").change(function () {
                var selectedItem = $(this).val();
                var ddlStates = $("#@Html.FieldIdFor(model => model.StateProvinceId)");
             var statesProgress = $("#states-loading-progress");
             statesProgress.show();
             $.ajax({
                 cache: false,
                 type: "GET",
                 url: "@(Url.RouteUrl("GetStatesByCountryId"))",
                 data: { "countryId": selectedItem, "addSelectStateItem": "true" },
                    success: function (data) {
                        ddlStates.html('');
                        $.each(data, function (id, option) {
                            ddlStates.append($('<option></option>').val(option.id).html(option.name));
                        });
                        statesProgress.hide();
                    },
                    error: function (xhr, ajaxOptions, thrownError) {
                        alert('Failed to retrieve states.');
                        statesProgress.hide();
                    }
                });
            });
        });
    </script>
}



<div class="features_items my-account-page"><!--features_items-->
    <h2 class="title text-center">@T("Account.MyAccount") - @T("Account.CustomerInfo")</h2>
    <div class="custom-page-box-div">
        @using (Html.BeginForm())
        {
            @Html.AntiForgeryToken()
            <div class="message-error">
                @Html.ValidationSummary(true)
            </div>
            <div class="fieldset">
                <div id="legend">
                    <legend >@T("Account.YourPersonalDetails")</legend>
                </div>
                <div class="form-fields">
                    @if (Model.GenderEnabled)
                    {
                        <div class="form-group row">
                            <label class="col-md-2 " >@T("Account.Fields.Gender"):</label>
                            <div class="col-md-9">
                                @Html.RadioButton("Gender", "M", (Model.Gender == "M"), new { id = "gender-male" })
                                <label class="forcheckbox  " for="gender-male">@T("Account.Fields.Gender.Male")</label>
                                @Html.RadioButton("Gender", "F", (Model.Gender == "F"), new { id = "gender-female" })
                                <label class="forcheckbox " for="gender-female">@T("Account.Fields.Gender.Female")</label>
                            </div>
                        </div>
                    }
                    <div class="form-group row">
                        <div class="col-md-2"> 
                            @Html.LabelFor(model => model.FirstName, new { @class = "col-md- control-label" }, ":")
                        </div>
                        <div class="col-md-6">
                            @Html.TextBoxFor(model => model.FirstName, new { @class = "gray-input" })
                        </div>
                        <div class="col-md-2" >
                            
                            @Html.RequiredHint()
                            @Html.ValidationMessageFor(model => model.FirstName)
                        </div>     
                    </div>
                    <div class="form-group row">
                        <div class="col-md-2 ">
                            @Html.LabelFor(model => model.LastName, new { @class = "" }, ":")
                        </div>
                        <div class="col-md-6">
                            @Html.TextBoxFor(model => model.LastName, new { @class = "gray-input" })
                        </div>
                        <div class="col-md-2">
                            @Html.RequiredHint()
                            @Html.ValidationMessageFor(model => model.LastName)
                        </div>
                    </div>
                    @if (Model.DateOfBirthEnabled)
                    {
                        <div class="form-group row">
                            <label class="col-md-2">@T("Account.Fields.DateOfBirth"):</label>
                            <div class="col-md-6 datepicker-dropdowns">
                                @Html.DatePickerDropDowns(Html.FieldNameFor(x => x.DateOfBirthDay),
                                                          Html.FieldNameFor(x => x.DateOfBirthMonth),
                                                          Html.FieldNameFor(x => x.DateOfBirthYear),
                                                          DateTime.Now.Year - 110,
                                                          DateTime.Now.Year,
                                                          Model.DateOfBirthDay,
                                                          Model.DateOfBirthMonth,
                                                          Model.DateOfBirthYear)
                                @Html.ValidationMessageFor(model => model.DateOfBirthDay)
                                @Html.ValidationMessageFor(model => model.DateOfBirthMonth)
                                @Html.ValidationMessageFor(model => model.DateOfBirthYear)
                            </div>
                        </div>
                    }
                    <div class="form-group row">
                        <div class="col-md-2 ">
                            @Html.LabelFor(model => model.Email, new { @class = "" }, ":")
                        </div>
                        <div class="col-md-6">
                            @Html.TextBoxFor(model => model.Email, new { @class = "gray-input" })
                        </div>
                        <div class="col-md-2">
                            @Html.RequiredHint()
                            @Html.ValidationMessageFor(model => model.Email)
                        </div>
                    </div>

                    @if (Model.UsernamesEnabled)
                    {
                        if (Model.AllowUsersToChangeUsernames)
                        {
                            <div class="form-group row">
                                <div class="col-md-2 ">
                                    @Html.LabelFor(model => model.Username, new { @class = "" }, ":")
                                </div>

                                <div class="col-md-6">
                                    @Html.TextBoxFor(model => model.Username, new { @class = "gray-input" })
                                </div>
                                <div class="col-md-4">
                                    @Html.RequiredHint()
                                    @Html.ValidationMessageFor(model => model.Username)
                                    @if (Model.CheckUsernameAvailabilityEnabled)
                                    {
                                        @Html.Partial("_CheckUsernameAvailability")
                                    }
                                </div>
                            </div>
                        }
                        else
                        {
                            <div class="form-group row">
                                @Html.LabelFor(model => model.Username, new { @class = "" }, ":")
                                <div class="col-md-10">
                                    @Model.Username
                                </div>
                            </div>
                        }
                    }
                </div>
            </div>    
            if (Model.AssociatedExternalAuthRecords.Count > 0)
            {
                <div class="fieldset">
                <div id="legend">
                    <legend >@T("Account.AssociatedExternalAuth")</legend>
                </div>

                    <div id="cart_items">
    

                        <div class="table-responsive cart_info">
                            <table class="table table-condensed">
                                <thead>
                                    <tr class="cart_menu">
                                        <td class="a-center auth-method-name">
                                            @T("Account.AssociatedExternalAuth.AuthMethodName")
                                        </td>
                                        <td class="a-center email">
                                            @T("Account.AssociatedExternalAuth.Email")
                                        </td>
                                        <td class="a-center external-id">
                                            @T("Account.AssociatedExternalAuth.ExternalIdentifier")
                                        </td>
                
                                    </tr>

                                </thead>

                                <tbody>
                                    @foreach (var item in Model.AssociatedExternalAuthRecords)
                                    {
                                        <tr>
                                            <td class="a-left auth-method-name">
                                                @item.AuthMethodName
                                            </td>
                                            <td class="a-left email">
                                                @item.Email
                                            </td>
                                            <td class="a-left external-id">
                                                @CommonHelper.EnsureMaximumLength(item.ExternalIdentifier, 40, "...")
                                            </td>
                                        </tr>
                                    }
            
                                </tbody>

                            </table>
                        </div>

                    </div>
                </div>


                

            }
            if (Model.CompanyEnabled || Model.DisplayVatNumber)
            {
                <div class="fieldset">
                    <div id="legend">
                        <legend class="">@T("Account.CompanyDetails")</legend>
                    </div>
                    <div class="form-fields">
                        @if (Model.CompanyEnabled)
                        {
                            <div class="form-group row">
                                <div class="col-md-2">
                                    @Html.LabelFor(model => model.Company, new { @class = "" }, ":")
                                </div>
                                <div class="col-md-6">
                                    @Html.TextBoxFor(model => model.Company, new { @class = "gray-input" })
                                </div>   
                                <div class="col-md-4"> 
                                    @if (Model.CompanyRequired)
                                    {
                                        @Html.RequiredHint()
                                    }
                                    @Html.ValidationMessageFor(model => model.Company)
                                </div>
                            </div>
                        }
                        @if (Model.DisplayVatNumber)
                        {
                            <div class="form-group row">
                                <div class="col-md-2">
                                @Html.LabelFor(model => model.VatNumber, new { @class = "" }, ":")
                                </div>
                                
                                <div class="col-md-6">
                                    @Html.TextBoxFor(model => model.VatNumber, new { @class = "gray-input" })
                                </div>
                                <div class="col-md-2"> 
                                    <span class="vat-status">@Model.VatNumberStatusNote</span>
                                </div>
                                <div class="col-md-2"> 
                                    <span class="vat-note"><em>@T("Account.Fields.VatNumber.Note")</em></span>
                                </div>
                            </div>
                        }
                    </div>
                </div>
            }
            if (Model.StreetAddressEnabled ||
                Model.StreetAddress2Enabled ||
                Model.ZipPostalCodeEnabled ||
                Model.CityEnabled ||
                Model.CountryEnabled)
            {
                <div class="fieldset">
                    <div id="legend">
                        <legend class="">@T("Account.YourAddress")</legend>
                    </div>
                    <div class="form-fields">
                        @if (Model.StreetAddressEnabled)
                        {
                            <div class="form-group row">
                                @Html.LabelFor(model => model.StreetAddress, new { @class = "col-md-2" }, ":")
                                <div class="col-md-6">
                                    @Html.TextBoxFor(model => model.StreetAddress, new { @class = "gray-input" })
                                </div>
                                <div class="col-md-4">                             
                                    @if (Model.StreetAddressRequired)
                                    {
                                        @Html.RequiredHint()
                                    }
                                    @Html.ValidationMessageFor(model => model.StreetAddress)
                                </div>
                            </div>
                        }
                        @if (Model.StreetAddress2Enabled)
                        {
                            <div class="form-group row">
                                @Html.LabelFor(model => model.StreetAddress2, new { @class = "col-md-2 " }, ":")
                                <div class="col-md-6">
                                    @Html.TextBoxFor(model => model.StreetAddress2, new { @class = "gray-input" })
                                </div>
                                <div class="col-md-4">                             
                                    @if (Model.StreetAddress2Required)
                                    {
                                        @Html.RequiredHint()
                                    }
                                    @Html.ValidationMessageFor(model => model.StreetAddress2)
                                </div>                               
                            </div>
                        }
                        @if (Model.ZipPostalCodeEnabled)
                        {
                            <div class="form-group row">
                                @Html.LabelFor(model => model.ZipPostalCode, new { @class = "col-md-2" }, ":")
                                <div class="col-md-6">
                                    @Html.TextBoxFor(model => model.ZipPostalCode, new { @class = "gray-input" })
                                </div>
                                <div class="col-md-4">
                                    @if (Model.ZipPostalCodeRequired)
                                    {
                                        @Html.RequiredHint()
                                    }
                                    @Html.ValidationMessageFor(model => model.ZipPostalCode)
                                </div>
                            </div>
                        }
                        @if (Model.CityEnabled)
                        {
                            <div class="form-group row">
                                @Html.LabelFor(model => model.City, new { @class = "col-md-2" }, ":")
                                <div class="col-md-6">    
                                    @Html.TextBoxFor(model => model.City, new { @class = "gray-input" })
                                </div>
                                <div class="col-md-4">
                                    @if (Model.CityRequired)
                                    {
                                        @Html.RequiredHint()
                                    }
                                    @Html.ValidationMessageFor(model => model.City)
                                </div>
                            </div>
                        }
                        @if (Model.CountryEnabled)
                        {
                            <div class="form-group row">
                                @Html.LabelFor(model => model.CountryId, new { @class = "col-md-2" }, ":")
                                <div class="col-md-6">    
                                    @Html.DropDownList("CountryId", Model.AvailableCountries, new { @class = "gray-dropdown" })
                                </div>    
                            </div>
                        }
                        @if (Model.CountryEnabled && Model.StateProvinceEnabled)
                        {
                            <div class="form-group row">
                                @Html.LabelFor(model => model.StateProvinceId, new { @class = "col-md-2" }, ":")
                                <div class="col-md-6">    
                                    @Html.DropDownList("StateProvinceId", Model.AvailableStates, new { @class = "gray-dropdown" })
                                    <span id="states-loading-progress" style="display: none;" class="please-wait">@T("Common.Wait...")</span>
                                </div>
                            </div>
                        }
                    </div>
                </div>            
            }
            if (Model.PhoneEnabled || Model.FaxEnabled)
            {
                <div class="fieldset">
                    <div id="legend">
                        <legend class="">@T("Account.YourContactInformation")</legend>
                    </div>
                    <div class="form-fields">
                        @if (Model.PhoneEnabled)
                        {
                            <div class="form-group row">
                                @Html.LabelFor(model => model.Phone, new { @class = "col-md-2" }, ":")
                                <div class="col-md-6">    
                                    @Html.TextBoxFor(model => model.Phone, new { @class = "gray-input" })
                                </div>
                                <div class="col-md-4">
                                    @if (Model.PhoneRequired)
                                    {
                                        @Html.RequiredHint()
                                    }
                                    @Html.ValidationMessageFor(model => model.Phone)
                                </div>
                            </div>
                        }
                        @if (Model.FaxEnabled)
                        {
                            <div class="form-group row">
                                @Html.LabelFor(model => model.Fax, new { @class = "col-md-2" }, ":")
                                <div class="col-md-6">    
                                    @Html.TextBoxFor(model => model.Fax, new { @class = "gray-input" })
                                </div>
                                <div class="col-md-4">
                                    @if (Model.FaxRequired)
                                    {
                                        @Html.RequiredHint()
                                    }
                                    @Html.ValidationMessageFor(model => model.Fax)
                                </div>
                            </div>
                        }
                    </div>
                </div>
            }
            if (Model.NewsletterEnabled || Model.CustomerAttributes.Count > 0)
            {
                <div class="fieldset">
                    <div id="legend">
                        <legend class="">@T("Account.Options")</legend>
                    </div>
                    <div class="form-fields">
                        @if (Model.NewsletterEnabled)
                        {
                            <div class="form-group row">
                                <div class="col-md-2">
                                    @Html.LabelFor(model => model.Newsletter, new {@class = ""}, ":")
                                </div>
                                <div class="col-md-6">    
                                    @Html.EditorFor(model => model.Newsletter, new {@class = ""})
                                </div>
                                <div class="col-md-4">
                                    @Html.ValidationMessageFor(model => model.Newsletter)
                                </div>
                            </div>
                        }
                        @if (Model.CustomerAttributes.Count > 0)
                        {
                            @Html.Partial("_CustomerAttributes", Model.CustomerAttributes)
                        }

                    </div>
                </div>
            }
            if (Model.AllowCustomersToSetTimeZone || Model.SignatureEnabled)
            { 
                <div class="fieldset">
                    <div id="legend">
                        <legend class="">@T("Account.Preferences")</legend>
                    </div>
                    <div class="form-fields">
                        @if (Model.AllowCustomersToSetTimeZone)
                        {
                            <div class="form-group row">
                                @Html.LabelFor(model => model.TimeZoneId, new { @class = "col-md-2" }, ":")
                                <div class="col-md-6">    
                                    @Html.DropDownList("TimeZoneId", Model.AvailableTimeZones, new { @class = "gray-dropdown" })                                    
                                </div>
                                <div class="col-md-4">
                                    @Html.ValidationMessageFor(model => model.TimeZoneId)
                                </div>
                            </div>
                        }
                        @if (Model.SignatureEnabled)
                        {
                            <div class="form-group row">
                                <div class="col-md-2">
                                    @Html.LabelFor(model => model.Signature, new { @class = "" }, ":")
                                </div>
                                <div class="col-md-6">    
                                    @Html.TextAreaFor(model => model.Signature, new { @class = "gray-textarea" })                                  
                                </div>
                            </div>
                        }
                    </div>
                </div>
            }
            <div class="row">
                <div class="col-md-12">
                    <div class="buttons pull-right">
                    <input type="submit" value="@T("Common.Save")" name="save-info-button" class="button-1 register-next-step-button btn btn-primary" />
                </div>    
                </div>
                
            </div>

            
        }
    </div>
</div>


